<!DOCTYPE html>
<html>
	<head>
		<title>
			screen 1
		</title>
	</head>

<body>
<?php

	//constraints:
	require_once '../database/sql.php'; //info to connect to mysql
	require_once '../modules/customer.php'; //contains customer class
	session_start(); //begin session to access global data

/*******************************Second Perspective******************************/
	if($_POST) {

		//process order
		if($_POST['order']) {
			foreach($_SESSION['left_side_object'] as $value) 
				//if($_SESSION['customer']->plate == $value)
					//echo "True: $index\n";
				$_SESSION['customer']->plate($value);

			//write contents to file
			file_put_contents('../tables/table1',$_SESSION['customer']->output());
		}

		//terminate session
		if($_POST['logout']) {
			unset($_SESSION['customer']);
        	unset($_SESSION['right_side']);
        	unset($_SESSION['left_side']);
        	unset($_SESSION['left_side_item']);
			unset($_SESSION['left_side_object']);
        	unset($_SESSION['bottom_side']);
        	unset($_SESSION['bottom_side_item']);
        	unset($_SESSION['customer_plates']);
		}
/*****************************modify****************************************/
		//check the session for the object
		if($_SESSION['customer']) {
			//$customer = $_SESSION['customer']; //set the object
			$_SESSION['customer']->meal($_POST); //make part of the customer
			echo '<pre>' . $_SESSION['customer']->output() . "</pre>\n";
			file_put_contents('../tables/table1',$_SESSION['customer']->output());

		} //end check
/*****************************modify****************************************/

	} //conclude second perspective


/*******************************First Perspective********************************/

	//store global object
	if(!$_SESSION['customer']) {
		$customer = new CUSTOMER(1.1); //create customer at table number
		$_SESSION['customer'] = $customer; //store in session
	} // end global storage

	//commence table
	echo '<table border="1">';
	echo "<tr>\n";

	//process Drinks menu
	echo "<form method=\"post\" action=\"../drinks_page/drinks.php\">\n";
	echo "<td><input type=\"submit\" name=\"drinks\" value=\"Drinks\"/></td>\n";
	echo "</form>\n";

	//process Food menu
	echo "<form method=\"post\" action=\"../menu_page/menu.php\">\n";
	echo "<td><input type=\"submit\" name=\"menu\" value=\"Menu\"/></td>\n";
	echo "</form>\n";

	echo "</tr>\n<tr>\n"; //break table column

	//process Ticket screen
	echo "<form method=\"post\" action=\"ticket.php\">\n";
	echo "<td><input type=\"submit\" name=\"ticket\" value=\"Ticket\"/></td>\n";
	echo "</form>\n";

	//process Feedback screen
	echo "<form method=\"post\" action=\"feedback.php\">\n";
	echo "<td><input type=\"submit\" name=\"feedback\" value=\"Feedback\"/></td>\n";
	echo "</form>\n";

	echo "</tr>\n"; //conclude rows
	echo "</table>\n"; //conclude table

	echo "<form method=\"post\">\n";
	echo "<input type=\"submit\" name=\"logout\" value=\"LogOut\" />\n"; //end the session
	echo "</form>\n";

?>
</body>

</html>
